-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix TF issue 4151: azurerm_app_service blocks not working as expected #4328
Conversation
Thanks for this PR. Unfortunately the AppSettings and Connection Strings on the resource "azurerm_resource_group" "test" {
name = "some-resource-group"
location = "West Europe"
}
resource "azurerm_app_service_plan" "test" {
name = "example-appserviceplan"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
sku {
tier = "Standard"
size = "S1"
}
}
resource "azurerm_app_service" "test" {
name = "example-appservice"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
app_service_plan_id = "${azurerm_app_service_plan.test.id}"
}
resource "azurerm_app_service_slot" "first" {
name = "first"
app_service_name = "${azurerm_app_service.test.name}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
app_service_plan_id = "${azurerm_app_service_plan.test.id}"
site_config {
dotnet_framework_version = "v4.0"
}
app_settings = {
"SOME_KEY" = "some-value"
}
connection_string {
name = "Database"
type = "SQLServer"
value = "Server=some-server.mydomain.com;Integrated Security=SSPI"
}
}
resource "azurerm_app_service_slot" "second" {
name = "second"
app_service_name = "${azurerm_app_service.test.name}"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
app_service_plan_id = "${azurerm_app_service_plan.test.id}"
site_config {
dotnet_framework_version = "v4.0"
}
app_settings = {
"SOME_KEY" = "some-other-value"
}
connection_string {
name = "Database"
type = "SQLServer"
value = "Server=some-other-server.mydomain.com;Integrated Security=SSPI"
}
}
resource "azurerm_app_service_active_slot" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
app_service_name = "${azurerm_app_service.test.name}"
app_service_slot_name = "${azurerm_app_service_slot.first.name}"
} Where changing the As such you can instead empty these blocks out by assigning an empty list to them; as shown below:
As such whilst I'd like to thank you for this contribution I'm going to close this PR for the moment since this behaviour is intentional to support this use-case in the Azure API. Thanks! |
@tombuildsstuff , thanks for your comment but I still have some concerns on it. Could you help to explain it? Thanks. Question # 2: My sample code: resource "azurerm_app_service_plan" "test" { sku { resource "azurerm_app_service" "test" { connection_string = [] Question # 3: Question # 4: |
I'm having the same issue. Is there some update on this? |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
After tested, I found this is a bug for resource “azurerm_app_service”. User expects the configuration should be removed from app service after removed the “connection_string” settings from tf config file. Actually it won’t remove the configuration. After checked, the root cause is that the connection_string field is defined the attribute “Computed: true”, which means terraform won’t check the difference for field connection_string when the field connection_string isn’t specified in tf config file. After tested, I found the configuration can be deleted successfully after removed the attribute. And this doc "https://www.terraform.io/docs/providers/azurerm/r/app_service.html#connection_string" also instruct the field connection_string should be optional. So I’ve provided the fix.
Issue linked: terraform-providers#4151